/***
 * Implementation of js-simple-storage interface for localStorage
 *
 * The idea here is to keep things simple and extend the window
 * object until there are explicit requirements;
 */
(function(window, undefined) {
    var storage = window.storage || {},
        hasStorage = typeof window.localStorage !== undefined,
        _l = window.localStorage;

    storage.local = {
        enabled: function() {
            return hasStorage;
        },
        getItem: function(key) {
            return _l.getItem(key);
        },
        setItem: function(key, value) {
            _l.setItem(key, value);
        },
        removeItem: function(key, value) {
            _l.removeItem(key);
        },
        clear: function() {
            _l.clear();
        },
        keys: function() {
            var _keys = new Array();
            for (var i = 0; i < _l.length; i++) {
                _keys.push(_l.key(i));
            }
            return _keys;
        }
    };
    
    window.storage = storage;
    window.storage.local = storage.local;
})(window);
